<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: demoFoxmlToLucene.xslt 5734 2006-11-28 11:20:15Z gertsp $ -->
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:k="ddi:codebook:2_5" exclude-result-prefixes="k">
	<xsl:strip-space elements="codeBook"/>
	<xsl:output method="xml" indent="yes" encoding="UTF-8" />
	<xsl:variable name="TemplateName" select="k:codeBook/@version" />
	<xsl:template match="/">
		<results>
			<!-- <value><xsl:value-of select="$TemplateName" /></value> -->
			<xsl:choose>
				<xsl:when test="$TemplateName='2.5'">
					<xsl:apply-templates mode="ddi25" />
				</xsl:when>
				<xsl:when test="$TemplateName='2.1'">
					<xsl:apply-templates mode="ddi21" />
				</xsl:when>
				<xsl:otherwise>
					<xsl:apply-templates mode="ddi1" />
				</xsl:otherwise>
			</xsl:choose>
			<!-- <xsl:apply-templates mode="activeDdi" /> -->
		</results>
	</xsl:template>
	<xsl:template match="codeBook" mode="ddi1">
		<entro>ENTRO AQUI 1.2.2</entro>
		<xsl:for-each select="stdyDscr/citation/prodStmt/*">
			<xsl:if test="name() = 'producer'">
				<field>
					<xsl:attribute name="name">
						<xsl:value-of select="'dataCollector'" />
					</xsl:attribute>
					<xsl:value-of select="text()" />
				</field>
			</xsl:if>
		</xsl:for-each>
		<xsl:for-each select="stdyDscr/stdyInfo/sumDscr/*">
			<xsl:if test="name() = 'universe'">
				<field>
					<xsl:attribute name="name">
						<xsl:value-of select="'universe'" />
					</xsl:attribute>
					<xsl:value-of select="text()" />
				</field>
			</xsl:if>
		</xsl:for-each>
		<xsl:for-each select="stdyDscr/stdyInfo/*">
			<xsl:if test="name() = 'abstract'">
				<field>
					<xsl:attribute name="name">
						<xsl:value-of select="'description'" />
					</xsl:attribute>
					<xsl:value-of select="text()" />
				</field>
			</xsl:if>
		</xsl:for-each>
		<xsl:for-each select="stdyDscr/method/dataColl/*">
			<xsl:choose>
				<xsl:when test="name() = 'timeMeth'">
					<field>
						<xsl:attribute name="name">
							<xsl:value-of select="'timeMethod'" />
						</xsl:attribute>
						<xsl:value-of select="text()" />
					</field>
				</xsl:when>
				<xsl:when test="name() = 'sampProc'">
					<field>
						<xsl:attribute name="name">
							<xsl:value-of select="'samplingProcedure'" />
						</xsl:attribute>
						<xsl:value-of select="text()" />
					</field>
				</xsl:when>
				<xsl:when test="name() = 'collMode'">
					<field>
						<xsl:attribute name="name">
							<xsl:value-of select="'collectionMode'" />
						</xsl:attribute>
						<xsl:value-of select="text()" />
					</field>
				</xsl:when>
				<xsl:otherwise></xsl:otherwise>
			</xsl:choose>
		</xsl:for-each>
	</xsl:template>
	<xsl:template match="codeBook" mode="ddi21">
		<!-- <entro>ENTRO AQUI 2.1</entro> -->
		<xsl:for-each select="stdyDscr/citation/prodStmt/*">
			<xsl:if test="name() = 'producer'">
				<field>
					<xsl:attribute name="name">
						<xsl:value-of select="'dataCollector'" />
					</xsl:attribute>
					<xsl:value-of select="text()" />
				</field>
			</xsl:if>
		</xsl:for-each>
		<xsl:for-each select="stdyDscr/stdyInfo/*">
			<xsl:if test="name() = 'abstract'">
				<field>
					<xsl:attribute name="name">
						<xsl:value-of select="'description'" />
					</xsl:attribute>
					<xsl:value-of select="text()" />
				</field>
			</xsl:if>
		</xsl:for-each>
		<xsl:for-each select="stdyDscr/stdyInfo/sumDscr/*">
			<xsl:if test="name() = 'universe'">
				<field>
					<xsl:attribute name="name">
						<xsl:value-of select="'universe'" />
					</xsl:attribute>
					<xsl:value-of select="text()" />
				</field>
			</xsl:if>
		</xsl:for-each>
		<xsl:for-each select="stdyDscr/method/dataColl/*">
			<xsl:choose>
				<xsl:when test="name() = 'timeMeth'">
					<field>
						<xsl:attribute name="name">
							<xsl:value-of select="'timeMethod'" />
						</xsl:attribute>
						<xsl:value-of select="text()" />
					</field>
				</xsl:when>
				<xsl:when test="name() = 'sampProc'">
					<field>
						<xsl:attribute name="name">
							<xsl:value-of select="'samplingProcedure'" />
						</xsl:attribute>
						<xsl:value-of select="text()" />
					</field>
				</xsl:when>
				<xsl:when test="name() = 'collMode'">
					<field>
						<xsl:attribute name="name">
							<xsl:value-of select="'collectionMode'" />
						</xsl:attribute>
						<xsl:value-of select="text()" />
					</field>
				</xsl:when>
				<xsl:when test="name() = 'dataCollector'">
					<field>
						<xsl:attribute name="name">
							<xsl:value-of select="'dataCollector'" />
						</xsl:attribute>
						<xsl:value-of select="text()" />
					</field>
				</xsl:when>
				<xsl:otherwise></xsl:otherwise>
			</xsl:choose>
		</xsl:for-each>
	</xsl:template>
	<xsl:template match="k:codeBook" mode="ddi25">
		<!-- <entro>ENTRO AQUI 2.5</entro> -->
		<xsl:for-each select="k:stdyDscr/k:citation/k:prodStmt/*">
			<xsl:if test="name() = 'producer'">
				<field>
					<xsl:attribute name="name">
						<xsl:value-of select="'dataCollector'" />
					</xsl:attribute>
					<xsl:value-of select="text()" />
				</field>
			</xsl:if>
		</xsl:for-each>
		<xsl:for-each select="k:stdyDscr/k:stdyInfo/*">
			<xsl:if test="name() = 'abstract'">
				<field>
					<xsl:attribute name="name">
						<xsl:value-of select="'description'" />
					</xsl:attribute>
					<xsl:value-of select="text()" />
				</field>
			</xsl:if>
		</xsl:for-each>
		<xsl:for-each select="k:stdyDscr/k:stdyInfo/k:sumDscr/*">
			<xsl:if test="name() = 'universe'">
				<field>
					<xsl:attribute name="name">
						<xsl:value-of select="'universe'" />
					</xsl:attribute>
					<xsl:value-of select="text()" />
				</field>
			</xsl:if>
		</xsl:for-each>
		<xsl:for-each select="k:stdyDscr/k:method/k:dataColl/*">
			<xsl:choose>
				<xsl:when test="name() = 'timeMeth'">
					<field>
						<xsl:attribute name="name">
							<xsl:value-of select="'timeMethod'" />
						</xsl:attribute>
						<xsl:value-of select="text()" />
					</field>
				</xsl:when>
				<xsl:when test="name() = 'sampProc'">
					<field>
						<xsl:attribute name="name">
							<xsl:value-of select="'samplingProcedure'" />
						</xsl:attribute>
						<xsl:value-of select="text()" />
					</field>
				</xsl:when>
				<xsl:when test="name() = 'collMode'">
					<field>
						<xsl:attribute name="name">
							<xsl:value-of select="'collectionMode'" />
						</xsl:attribute>
						<xsl:value-of select="text()" />
					</field>
				</xsl:when>
				<xsl:when test="name() = 'dataCollector'">
					<field>
						<xsl:attribute name="name">
							<xsl:value-of select="'dataCollector'" />
						</xsl:attribute>
						<xsl:value-of select="text()" />
					</field>
				</xsl:when>
				<xsl:otherwise></xsl:otherwise>
			</xsl:choose>
		</xsl:for-each>
	</xsl:template>
</xsl:stylesheet>	
